﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Utpl.Syllabus.Reconocimiento.Web.Login" %>

<%@ Register TagPrefix="syllabus" TagName="ucRolesUsuario" Src="ucRolesUsuario.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" runat="server" />
    <title>Login - Syllabus</title>
</head>
<body>
    <%--**********************************************************************************************--%>
    <%--************************                Manejadores                   ************************--%>
    <%--**********************************************************************************************--%>
    <%--Control base para el uso de Ext.Net--%>
    <ext:ResourceManager ID="rsmPrincipal" runat="server" />
    <%--**********************************************************************************************--%>
    <%--************************                  Formulario                  ************************--%>
    <%--**********************************************************************************************--%>
    <%--Contenedor Principal--%>
    <ext:Window ID="winLogin" runat="server" Closable="false" Resizable="false" Height="150"
        DefaultButton="btnIngresar" Title="<%$ Res: Textos.Login %>" Draggable="false"
        Width="300" Modal="true" Padding="5" ButtonAlign="Center">
        <Items>
            <ext:FormPanel ID="frpLogin" runat="server" BodyStyle="background-color:transparent;"
                Border="false" Layout="Form">
                <Items>
                    <ext:TextField ID="txfNombreUsuario" runat="server" FieldLabel="<%$ Res: Textos.Usuario %>"
                        BlankText="<%$ Res: Textos.IngreseNombreUsuario %>" AnchorHorizontal="100%">
                        <CustomConfig>
                            <ext:ConfigItem Name="propiedadObjeto" Value="SyUsernameCriteria.UserName" Mode="Value" />
                        </CustomConfig>
                    </ext:TextField>
                    <ext:TextField ID="txfContraseña" runat="server" InputType="Password" FieldLabel="<%$ Res: Textos.Contraseña %>"
                        BlankText="<%$ Res: Textos.IngreseContraseña %>" AnchorHorizontal="100%">
                        <CustomConfig>
                            <ext:ConfigItem Name="propiedadObjeto" Value="SyUsernameCriteria.Clave" Mode="Value" />
                        </CustomConfig>
                    </ext:TextField>
                </Items>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button ID="btnIngresar" runat="server" Text="<%$ Res: Textos.Ingresar %>" >
                <Listeners>
                    <Click Handler="login()" />
                </Listeners>
            </ext:Button>
        </Buttons>
        <KeyMap>
            <ext:KeyBinding>
                <Keys>
                    <ext:Key Code="ENTER" />
                </Keys>
                <Listeners>
                    <Event Handler="login()" />
                </Listeners>
            </ext:KeyBinding>
        </KeyMap>
    </ext:Window>
    <ext:XScript ID="XScript1" runat="server">
    <script type="text/javascript">                 
    
   var login = function() {
        panelLogin = #{frpLogin}.getForm();
        if(panelLogin.isValid())
        {     
                           
            var usuario = #{txfNombreUsuario}.getValue();
            var contrasena = #{txfContraseña}.getValue();

            Ext.net.DirectMethods.Ingresar(usuario, contrasena,{
                    success: function(response, result) {                                             
                        #{winRoles}.show();
                    },
                    eventMask:
                    {
                        showMask: true,
                        minDelay: 500,
                        removeMask: true
                    },
                    failure:Syllabus.Js.catchErrorDirectMethods                                        
                });
        }
        else
        {                      
            Sy.showMsgAlerta(Sy.Recursos.get('Mensajes.DatosIncompletos'));
        }        
    };    

    if (window.parent.length > 0){ window.parent.location = '/Login.aspx'; };
                    
    </script>
    </ext:XScript>
    <syllabus:ucRolesUsuario ID="ucRolesUsuario" runat="server"></syllabus:ucRolesUsuario>
</body>
</html>
